﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Docentric.Examples.Data.BusinessObjects.DataModel
{
    public class Order
    {
        public long Id { get; set; }
        public DateTime OrderDate { get; set; }
        public DateTime? ShippedDate { get; set; }
        public string ShipName { get; set; }
        public Address ShipAddress { get; set; }
        public decimal ShippingFee { get; set; }
        public decimal Taxes { get; set; }
        public string PaymentType { get; set; }
        public DateTime? PaidDate { get; set; }
        public string Notes { get; set; }
        public decimal TaxRate { get; set; }
        public OrderStatus Status { get; set; }


        #region Navigation properties
        private Customer _customer;
        public Customer Customer
        {
            get
            {
                return _customer;
            }
            set
            {
                if (_customer != null && _customer.Orders.Contains(this)) _customer.Orders.Remove(this);
                _customer = value;
                if (_customer != null) _customer.Orders.Add(this);
            }
        }


        private List<OrderDetail> _orderDetails = new List<OrderDetail>();
        public List<OrderDetail> OrderDetails
        {
            get
            {
                return _orderDetails;
            }
        }
        #endregion
    }



    public enum OrderStatus
    {
        New,
        Invoiced,
        Shipped,
        Closed
    }
}
